package cn.village.service.impl;

import cn.village.dao.LeaseContractDao;
import cn.village.entity.LeaseContract;
import cn.village.service.LeaseContractService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (LeaseContract)表服务实现类
 *
 * @author makejava
 * @since 2021-02-10 15:34:02
 */
@Service("leaseContractService")
public class LeaseContractServiceImpl implements LeaseContractService {
    @Resource
    private LeaseContractDao leaseContractDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public LeaseContract queryById(Integer id) {
        return this.leaseContractDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<LeaseContract> queryAllByLimit(int offset, int limit) {
        return this.leaseContractDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param leaseContract 实例对象
     * @return 实例对象
     */
    @Override
    public LeaseContract insert(LeaseContract leaseContract) {
        this.leaseContractDao.insert(leaseContract);
        return leaseContract;
    }

    /**
     * 修改数据
     *
     * @param leaseContract 实例对象
     * @return 实例对象
     */
    @Override
    public LeaseContract update(LeaseContract leaseContract) {
        this.leaseContractDao.update(leaseContract);
        return this.queryById(leaseContract.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.leaseContractDao.deleteById(id) > 0;
    }
}